// 将 require 改为 import
import { Model } from 'sutando';
import AdminRoles from './AdminRoles.ts'; // 注意添加 .js 扩展名
import dayjs from 'dayjs';

export default class AdminUsers extends Model {
  table = 'admin_users';
  primaryKey = 'id';
  timestamps = true;

  serializeDate(date) {
    return dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  }

  relationRoles() {
    return this.belongsToMany(AdminRoles, 'admin_role_users', 'user_id', 'role_id');
  }
}